﻿@{
    ViewBag.Title = "CompanyListInfo";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<style>
    .sub_nav li a {
        width: 100px;
    }
</style>
<div class="mod_containter" style="height: 100%" id="idmod_containter">
    <div class="main" id="idmain">
        <div class="mod_load" id="mod_load">
            <div class="mod_hd" id="idmod_hd">
                <h2 class="title">监控管理</h2>
                <div style="float:right">
                    <a class="white" id="aLoginOut">退出登录</a>
                    &nbsp;&nbsp;
                    <script type="text/javascript">

                        $("#aLoginOut").click(function () {
                            top.window.location.href = "/";

                        }).mouseover(function () {

                            $("#aLoginOut").toggleClass("red");
                        });

                    </script>
                    <style>
                        .red {
                            color: red;
                            font-size: 14px;
                            cursor: pointer;
                        }

                        .white {
                            color: white;
                            font-size: 14px;
                            cursor: pointer;
                        }
                    </style>
                </div>
            </div>
            <div class="mod_bd">
                <div class="sub_nav" id="sub_nav">
                    <ul>
                        <li><a href="/Monitor/MonitorListInfo">用料统计</a></li>
                        <li class="on"><a href="/Monitor/MonitorMachineListInfo">按机床</a></li>
                    </ul>
                </div>
                <div class="func_box" id="divBox">
                    <div class="inpt_box">
                        <input id="txtYear" type="text" placeholder="年份" lay-verify="number" style="width:40px" />
                        <input id="txtMonth" type="text" placeholder="月份" lay-verify="number" style="width:40px" />
                        <input id="txtMachine" type="text" placeholder="机床" style="width:80px" />
                    <input id="txtSearchContains" type="text" placeholder="请输入物料编码/规格/类型" /> </div>
                    <div class="btn_box"> <button id="btnSearch" class="btn_green_m" data-type="reload"><i class="ico ico_bsearch"></i>搜索</button> </div>
                    <a class="btn_add" id="btnAdd" data-type="user" href="javascript:;"><i class="ico ico_badd"></i>更新</a>
                </div>
                <table id="infoList" style="width: auto; position: fixed; bottom:20px;"></table>
                
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        var height =$(window).height();;
        var idmod_hd = $("#idmod_hd").height();
        var sub_nav = $("#sub_nav").height();
        var divBox = $("#divBox").height();
        
        var content = parseFloat(height) - parseFloat(idmod_hd) - parseFloat(sub_nav) - parseFloat(divBox)  - 120;
        $("#infoList").css("height", content);
    });
</script>

<script>
   
    ////easyuui

    $(function () {

        $("#infoList").datagrid({
            url: '/Monitor/MonitorMachineListInfoDetail',
            loadMsg: '数据加载中请稍后……',
            pagination: true,
            rownumbers: true,
            idField: "ID",
            nowrap: false,
            fitColumns: true,
            columns: [[
             { field: 'M_CODE', title: '物料编码', width: "15%", align: "center" }
            , { field: 'M_SPECIFICATION', title: '物料规格', width: "25%", align: "center" }
            , { field: 'M_TYPE', title: '物料类型', width: "15%", align: "center" }
            , { field: 'NUMBER', title: '数量', width: "10%", align: "center" }
            , { field: 'ACCOUNTYEAR', title: '年份', width: "10%", align: "center" }
            , { field: 'ACCOUNTMONTH', title: '月份', width: "10%", align: "center" }
            , { field: 'MACHINENAME', title: '机床号', width: "15%", align: "center" }
            ]],
            singleSelect: true,
            pageSize: 100,
            pageList: [20, 50, 100]
        });
    });

    $("#btnSearch").click(function () {
        var target = $("#infoList")[0];
        state = $.data(target, "datagrid");
        opts = state.options;
        var year = $("#txtYear").val();
        var patternyear = /^(19|20)\d{2}$/;
        if (year != "" & !patternyear.test(year))
        {
            layer.alert("请输入正确的年份！");
            return;
        }

        var month = $("#txtMonth").val();
        var patternmonth = /^([1-9]|1[0-2])$/;
        if (month != "" & !patternmonth.test(month)) {
            layer.alert("请输入正确的月份！");
            return;
        }
        opts.queryParams.SearchContains = $("#txtSearchContains").val();
        opts.queryParams.Year = year;
        opts.queryParams.Month = month;
        opts.queryParams.Machinename = $("#txtMachine").val();
        $("#infoList").datagrid("load", opts.queryParams);
    });

    $("#btnAdd").click(function () {
        com.ajax({
            url: "/Monitor/UpdateMaterialSummary",
            type: "post",
            dataType: "json",
            data: { summaryType: 0 },
            success: function (data) {
                $("#infoList").datagrid("load");
                layer.alert("更新成功！");
            }
        });
    });
</script>
